<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Perform GET request</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-persistent-handles-ident.html">http_persistent_handles_ident</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-head.html">http_head</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_get</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">http_get</span> &mdash; <span class="dc-title">Perform GET request</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.http-get-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>http_get</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$url</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$info</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Performs an HTTP GET request on the supplied url.
  </p>
  <p class="para">请查阅完整的 <a href="http.request.options.html" class="link">request 选项组</a> 列表。</p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.http-get-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">url</code></em></dt>

     <dd>

      <p class="para">
       URL
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">options</code></em></dt>

     <dd>

      <p class="para">
       <a href="http.request.options.html" class="link">request 选项组</a>
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">info</code></em></dt>

     <dd>

      <p class="para">
       Will be filled with request/response information
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.http-get-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时用字符串返回 HTTP 响应，失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-function.http-get-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4278">
    <p><strong>Example #1 A <span class="function"><strong>http_get()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$response&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">http_get</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.com/"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"timeout"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>array (
  &#039;effective_url&#039; =&gt; &#039;http://www.example.com/&#039;,
  &#039;response_code&#039; =&gt; 302,
  &#039;connect_code&#039; =&gt; 0,
  &#039;filetime&#039; =&gt; -1,
  &#039;total_time&#039; =&gt; 0.212348,
  &#039;namelookup_time&#039; =&gt; 0.038296,
  &#039;connect_time&#039; =&gt; 0.104144,
  &#039;pretransfer_time&#039; =&gt; 0.104307,
  &#039;starttransfer_time&#039; =&gt; 0.212077,
  &#039;redirect_time&#039; =&gt; 0,
  &#039;redirect_count&#039; =&gt; 0,
  &#039;size_upload&#039; =&gt; 0,
  &#039;size_download&#039; =&gt; 218,
  &#039;speed_download&#039; =&gt; 1026,
  &#039;speed_upload&#039; =&gt; 0,
  &#039;header_size&#039; =&gt; 307,
  &#039;request_size&#039; =&gt; 103,
  &#039;ssl_verifyresult&#039; =&gt; 0,
  &#039;ssl_engines&#039; =&gt;
  array (
    0 =&gt; &#039;dynamic&#039;,
    1 =&gt; &#039;cswift&#039;,
    2 =&gt; &#039;chil&#039;,
    3 =&gt; &#039;atalla&#039;,
    4 =&gt; &#039;nuron&#039;,
    5 =&gt; &#039;ubsec&#039;,
    6 =&gt; &#039;aep&#039;,
    7 =&gt; &#039;sureware&#039;,
    8 =&gt; &#039;4758cca&#039;,
  ),
  &#039;content_length_download&#039; =&gt; 218,
  &#039;content_length_upload&#039; =&gt; 0,
  &#039;content_type&#039; =&gt; &#039;text/html&#039;,
  &#039;httpauth_avail&#039; =&gt; 0,
  &#039;proxyauth_avail&#039; =&gt; 0,
  &#039;num_connects&#039; =&gt; 1,
  &#039;os_errno&#039; =&gt; 0,
  &#039;error&#039; =&gt; &#039;&#039;,
)</pre></div></div>
   </div>
  </p>
 </div>



 


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-persistent-handles-ident.html">http_persistent_handles_ident</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-head.html">http_head</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
